package com.iknow.xml.impl.dom;

import android.content.Context;
import com.iknow.util.LogUtil;
import com.iknow.xml.IKXmlResolve;
import java.io.File;
import java.io.InputStream;
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.xml.sax.InputSource;

public class IKDomResolve
  implements IKXmlResolve
{
  private DocumentBuilder docBuilder;
  private DocumentBuilderFactory docFactory;

  public IKDomResolve(Context paramContext)
  {
    try
    {
      this.docFactory = DocumentBuilderFactory.newInstance();
      this.docBuilder = this.docFactory.newDocumentBuilder();
      return;
    }
    catch (Exception localException)
    {
      LogUtil.e(this, localException);
    }
  }

  public Element getFileXml(File paramFile)
  {
    Element localElement;
    if (paramFile == null)
      localElement = null;
    while (true)
    {
      return localElement;
      if (paramFile.length() != 0L)
        break;
      localElement = null;
    }
    Object localObject = null;
    try
    {
      Document localDocument = this.docBuilder.parse(paramFile);
      localObject = localDocument;
      if (localObject == null)
        localElement = null;
    }
    catch (Exception localException)
    {
      while (true)
        LogUtil.e(super.getClass(), localException);
      localElement = localObject.getDocumentElement();
    }
  }

  public Object getXml(InputStream paramInputStream)
  {
    Object localObject = null;
    try
    {
      Element localElement = this.docBuilder.parse(new InputSource(paramInputStream)).getDocumentElement();
      localObject = localElement;
      return localObject;
    }
    catch (Exception localException)
    {
      LogUtil.e(super.getClass(), localException);
    }
  }

  public Object getXml(InputSource paramInputSource)
  {
    Object localObject = null;
    try
    {
      Element localElement = this.docBuilder.parse(paramInputSource).getDocumentElement();
      localObject = localElement;
      return localObject;
    }
    catch (Exception localException)
    {
      LogUtil.e(super.getClass(), localException);
    }
  }
}